package tk.mybatis.springboot.service.impl;

import net.sf.ehcache.CacheManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import tk.mybatis.springboot.common.Page;
import tk.mybatis.springboot.common.Result;
import tk.mybatis.springboot.common.base.BaseServiceImpl;
import tk.mybatis.springboot.mapper.CityMapper;
import tk.mybatis.springboot.model.City;
import tk.mybatis.springboot.service.ICityService;

import java.util.HashMap;
import java.util.List;

@Service
@Cacheable(cacheNames = "city")
public class CityServiceImpl extends BaseServiceImpl<CityMapper, City> implements ICityService {

    @Autowired
    CacheManager cacheManager;

    @Override
    @Cacheable(key = "#id")
    public City getById(Object id) throws Exception {
        return super.getById(id);
    }

    public Result<City> getRecordPage() throws Exception {
        Page page = new Page(1, 15);
        return super.getRecordPage("getRecordPage", page, new HashMap());
    }

    @Override
    public void savAll(List<City> list) throws Exception {

    }
}
